package com.tian.controller.management;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.tian.common.CommonResult;
import com.tian.dto.StationGunCommunicateLogQueryReqDto;
import com.tian.entity.StationGunCommunicateLog;
import com.tian.service.StationGunCommunicateLogService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import plus.ojbk.influxdb.core.InfluxdbTemplate;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * {@code @description:} 站枪通信日志管理
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-08-23 22:37
 * {@code @version:} 1.0
 */

@RestController
@RequestMapping("/management/station/gun/communicate/log")
public class StationGunCommunicateLogController {
    @Resource
    private StationGunCommunicateLogService stationGunCommunicateLogService;

    // 查询站枪通信日志
    @GetMapping("/list")
    public CommonResult<List<StationGunCommunicateLog>> list(@RequestParam("pageSize") Long pageSize, @RequestParam("currentPage") Long currentPage,
                                                             @RequestParam("logType") Integer logType, @RequestParam("gunNo") String gunNo,
                                                             @RequestParam("startLogTime") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startLogTime, @RequestParam("endLogTime") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDateTime endLogTime) {
        StationGunCommunicateLogQueryReqDto stationGunCommunicateLogQueryReqDto = new StationGunCommunicateLogQueryReqDto();
        stationGunCommunicateLogQueryReqDto.setPageSize(pageSize);
        stationGunCommunicateLogQueryReqDto.setCurrentPage(currentPage);
        stationGunCommunicateLogQueryReqDto.setLogType(logType);
        stationGunCommunicateLogQueryReqDto.setGunNo(gunNo);
        stationGunCommunicateLogQueryReqDto.setStartLogTime(LocalDateTime.now().minusDays(1));
        stationGunCommunicateLogQueryReqDto.setEndLogTime(LocalDateTime.now());
        return stationGunCommunicateLogService.getStationGunCommunicateLogList(stationGunCommunicateLogQueryReqDto);
    }
}
